package com.itheima.testjian;

import java.util.ArrayList;
import java.util.Iterator;

public class ZeQingFor {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student stu1 = new Student("小皮同学",23);
        Student stu2 = new Student("小六同学",26);
        Student stu3 = new Student("小夏同学",30);

        list.add(stu1);
        list.add(stu2);
        list.add(stu3);

        //迭代器方式遍历
        //创建迭代器对象
        Iterator<Student> it = list.iterator();
        while(it.hasNext()){
            Student s = it.next();
            System.out.println(s);
        }

        System.out.println("----------------");

        //增强For遍历
        for (Student student : list) {
            System.out.println(student);
        }
    }
}
